﻿using System;
using System.Runtime.Serialization;

namespace com.ddmresources.EnumMetadata.Core.Attributes
{
    /// <summary>
    /// This enumeration tells the EnumMetadata library what type of metadata attribute (static or dynamic) is decorating the the members 
    /// of the enum definition to which the EnumInfoSpecificationAttribute is applied
    /// </summary>
    public enum InfoModeOptions
    {
        Static = 1,
        Dynamic = 2
    }

    /// <summary>
    /// This is the core Attribute that makes the whole metadata system work. It decorates enum definitions (not instances), and its role is to 
    /// create the association between X type of custom metadata attribute that decorates an enum instance, and Y type of strongly typed metadata object
    /// that will eventually contain the data from the metadata attribute.
    /// </summary>
    [DataContract]
    [AttributeUsage(AttributeTargets.Enum, AllowMultiple = false, Inherited = false)]
    public class EnumInfoSpecificationAttribute: Attribute
    {
        #region Constructors
        /// <summary>
        /// This attribute is meaningless if it does not contain values for all three properties, so it cannot be constructed without this data being provided.
        /// </summary>
        /// <param name="infoMode">Whether the members of the enum definition are attributed with Static or Dynamic metadata attributes</param>
        /// <param name="metadataAttributeType">the type of the metadata attribute that actually decorates each enum instance member, 
        /// and is the design time container for the metadata</param>
        /// <param name="outputType">The type of the resulting metadata object that users of the EnumMetadata library will consume</param>
        public EnumInfoSpecificationAttribute(InfoModeOptions infoMode, Type metadataAttributeType, Type outputType)
        {
            this.InfoMode = infoMode;
            this.MetadataAttributeType = metadataAttributeType;
            this.OutputType = outputType;
        } 
        #endregion

        #region Properties

        /// <summary>
        /// Because the library must treat custom metadata attributes differently from the EnumDynamicInfoAttribute when it comes to moving data from the 
        /// attribute to the associated metadata object, this property signals the core logic of the library whether 
        /// </summary>
        [DataMember]
        public InfoModeOptions InfoMode { get; set; }

        /// <summary>
        /// The type of the metadata attribute that actually decorates each enum instance member, 
        /// and is the design time container for the metadata
        /// </summary>
        [DataMember]
        public Type MetadataAttributeType { get; set; }

        /// <summary>
        /// The type of the resulting metadata object that users of the EnumMetadata library will consume, 
        /// after the data has been pulled out of the metadata attribute and inserted into the metadata object. 
        /// </summary>
        [DataMember]
        public Type OutputType { get; set; }

        #endregion
    }
}
